package com.imooc.hadoop.spring;

/* 使用SpringBoot的方式访问HDFS
 * @Author Wangjin
 * @Date 2019-02-01
 * @Email wangjin4901@vip.qq.com
 */

import org.apache.hadoop.fs.FileStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.hadoop.fs.FsShell;

@SpringBootApplication
public class SpringBootHDFSApp implements CommandLineRunner{

    @Autowired
    FsShell fsShell;

    @Override
    public void run(String... strings) {
        for (FileStatus fileStatus : fsShell.lsr("/springhdfs")) {
            System.out.println("> " + fileStatus.getPath());
        }
    }

    public static void main(String[] args) {
        SpringApplication.run(SpringBootHDFSApp.class, args);
    }
}
